import 'package:flutter/material.dart';

class TitleWidget extends StatefulWidget {
  // const TitleWidget({Key? key}) : super(key: key);
  const TitleWidget(this.title, {Key? key}) : super(key: key);
  final String title;

  @override
  State<TitleWidget> createState() => _TitleWidgetState(title);
}

class _TitleWidgetState extends State<TitleWidget> {
  final String title;

  _TitleWidgetState(this.title);

  @override
  Widget build(BuildContext context) {
    return Container(
      constraints: BoxConstraints(
          minWidth: double.infinity, //宽度尽可能大
          minHeight: 50.0 //最小高度为50像素
      ),
      child: Stack(
        alignment:Alignment.center,
        fit: StackFit.loose,
        children: [
          Text(title,
              style: TextStyle(
                  color: Colors.black,
                  fontSize: 17,
                  fontWeight: FontWeight.bold)),
          Positioned(
              left: 10.0,
              child: IconButton(
                  onPressed: () {
                    Navigator.pop(context);
                  },
                  icon: Image(
                      width: 18,
                      height: 24,
                      image: AssetImage('images/home/ic_back.png'))))
        ],
      ),
    );
  }
}
